﻿@inherits BaseComponent

<ul class="kui-app-tab">
    @if (Items != null && Items.Count > 0)
    {
        foreach (var item in Items)
        {
            if (item.Target != "Tab")
                continue;

            <li @onclick="e=>OnItemClick(item)" class="@(current == item.Id ? "active" : "")">
                <Icon Type="@item.Icon" Theme="outline" />
                <span>@item.Name</span>
            </li>
        }
    }
</ul>

@code {
    private string current;

    [Parameter] public List<MenuInfo> Items { get; set; }

    protected override void OnInitialized()
    {
        base.OnInitialized();
        current = Items?.FirstOrDefault()?.Id;
    }

    private void OnItemClick(MenuInfo item)
    {
        current = item.Id;
        App?.NavigateTo(item);
    }
}